I am new in C#.
Below is my code this code I have done so far:
for (int row = 1; row <= 25; row++)
{
for (int col = 1; col <= 39; col++)
{
switch (row)
{
case 1:
Console.ForegroundColor = ConsoleColor.Red;
break;
case 2:
Console.ForegroundColor = ConsoleColor.White;
break;
case 3:
Console.ForegroundColor = ConsoleColor.Green;
break;
}
Console.Write("@ ");
}
Console.WriteLine();
}
In the above line of code, the first line is shows in red color after that all lines is shows in white color how can I achieve my task please anybody help me
All help is appreciated
Thanks
Anonymous User
05-Oct-2013Change your code in switch:
for (int row = 1; row <= 25; row++) {for (int col = 1; col <= 39; col++)
{
switch (row%3)
{
case 1:
Console.ForegroundColor = ConsoleColor. Red;
break;
case 2:
Console.ForegroundColor = ConsoleColor. White;
break;
case 0:
Console.ForegroundColor = ConsoleColor.Green;
break;
}
Console.Write("@ ");
}
Console.WriteLine();